home *** CD-ROM | disk | FTP | other *** search
/ Aminet 51 / Aminet 51 (2002)(GTI - Schatztruhe)[!][Oct 2002].iso / Aminet / util / arc / xadmasterdev.lha / xad / Sources / clients / xadIO.h < prev    next >
Encoding:
C/C++ Source or Header  |  2002-08-20  |  5.2 KB  |  128 lines

  1. #ifndef XADMASTER_XADIO_H
  2. #define XADMASTER_XADIO_H
  3.  
  4. /* Programmheader
  5.  
  6.     Name:        xadIO.h
  7.     Main:        xadmaster
  8.     Versionstring:    $VER: xadIO.h 1.6 (30.12.2001)
  9.     Author:        SDI
  10.     Distribution:    Freeware
  11.     Description:    input/output function header
  12.  
  13.  1.0   16.03.00 : first version
  14.  1.1   23.10.00 : added XIDFLAG_REACHEDEND
  15.  1.2   24.10.00 : renamed from xadInput.h
  16.  1.3   07.11.00 : moved xadIOPutChar, xadIOGetChar into structure to
  17.     support different functions
  18.  1.4   24.03.01 : added ReadBits versions
  19.  1.5   21.08.01 : added window elements
  20.  1.6   30.12.01 : added xadIOByteBoundary function
  21. */
  22.  
  23. #include <exec/types.h>
  24. #include <proto/xadmaster.h>
  25.  
  26. /* These are used to keep definitions in sync when called in source direct mode */
  27. #ifndef XADIODIRECTMODE
  28. #define XADIOFUNCMODE     extern
  29. #define XADIOFUNCMODEBITS extern
  30. #endif
  31.  
  32. typedef void (*XADINOUTFUNC)(struct xadInOut *io, ULONG size);
  33. typedef UBYTE (*XADINOUTPUT)(struct xadInOut *io, UBYTE data);
  34. typedef UBYTE (*XADINOUTGET)(struct xadInOut *io);
  35.  
  36. struct xadInOut {
  37.   struct xadArchiveInfo * xio_ArchiveInfo;        /* filled by xadIOAlloc */
  38.   struct xadMasterBase *  xio_xadMasterBase;        /* filled by xadIOAlloc */
  39.   LONG              xio_Error;            /* cleared */
  40.   ULONG              xio_Flags;            /* filled by xadIOAlloc, functions or user */
  41.  
  42.   XADINOUTGET          xio_GetFunc;            /* filled by xadIOAlloc or user */
  43.   APTR              xio_GetFuncPrivate;
  44.   XADINOUTPUT          xio_PutFunc;            /* filled by xadIOAlloc or user */
  45.   APTR              xio_PutFuncPrivate;
  46.  
  47.   XADINOUTFUNC              xio_InFunc;
  48.   APTR              xio_InFuncPrivate;
  49.   ULONG                   xio_InSize;
  50.   ULONG              xio_InBufferSize;
  51.   ULONG              xio_InBufferPos;
  52.   STRPTR          xio_InBuffer;
  53.   ULONG              xio_BitBuf;            /* for xadIOGetBits functions */
  54.   UWORD              xio_BitNum;            /* for xadIOGetBits functions */
  55.  
  56.   UWORD              xio_CRC16;            /* crc16 from output functions */
  57.   ULONG              xio_CRC32;            /* crc32 from output functions */
  58.  
  59.   XADINOUTFUNC              xio_OutFunc;
  60.   APTR              xio_OutFuncPrivate;
  61.   ULONG                   xio_OutSize;
  62.   ULONG              xio_OutBufferSize;
  63.   ULONG              xio_OutBufferPos;
  64.   STRPTR          xio_OutBuffer;
  65.  
  66.   ULONG                   xio_WindowSize;               /* This can be reused. Algorithms should be */
  67.   ULONG                   xio_WindowPos;                /* prepared to find this initialized! */
  68.   STRPTR                  xio_Window;                   /* The window, alloc always using xadAllocVec */
  69.  
  70.   /* If the algorithms need to remember additional data for next run, this should be passed
  71.      as argument structure of type (void **) and allocated by the algorithms themself using
  72.      xadAllocVec(). */
  73. };
  74.  
  75. /* setting BufferPos to buffer size activates first time read! */
  76.  
  77. #define XADIOF_ALLOCINBUFFER    (1<<0)    /* allocate input buffer */
  78. #define XADIOF_ALLOCOUTBUFFER    (1<<1)    /* allocate output buffer */
  79. #define XADIOF_NOINENDERR    (1<<2)    /* xadIOGetChar does not produce err at buffer end */
  80. #define XADIOF_NOOUTENDERR      (1<<3)  /* xadIOPutChar does not check out size */
  81. #define XADIOF_LASTINBYTE       (1<<4)  /* last byte was read, set by xadIOGetChar */
  82. #define XADIOF_LASTOUTBYTE      (1<<5)  /* output length was reached, set by xadIOPutChar */
  83. #define XADIOF_ERROR            (1<<6)    /* an error occured */
  84. #define XADIOF_NOCRC16        (1<<7)  /* calculate no CRC16 */
  85. #define XADIOF_NOCRC32        (1<<8)  /* calculate no CRC32 */
  86. #define XADIOF_COMPLETEOUTFUNC    (1<<9)    /* outfunc completely replaces write stuff */
  87.  
  88. /* allocates the xadInOut structure and the buffers */
  89. XADIOFUNCMODE struct xadInOut *xadIOAlloc(ULONG flags, struct xadArchiveInfo *ai, struct xadMasterBase *xadMasterBase);
  90.  
  91. /* writes the buffer out */
  92. XADIOFUNCMODE LONG xadIOWriteBuf(struct xadInOut *io);
  93.  
  94. #define xadIOGetChar(io)    (io)->xio_GetFunc((io))        /* reads one byte */
  95. #define xadIOPutChar(io,a)    (io)->xio_PutFunc((io), (a))    /* stores one byte */
  96.  
  97. /* This skips any left bits and rounds up the whole to next byte boundary. */
  98. /* Sometimes needed for block-based algorithms, where there blocks are byte aligned. */
  99. #define xadIOByteBoundary(io)    ((io)->xio_BitNum = 0)
  100.  
  101. /* The read bits function only read the bits without flushing from buffer. This is
  102. done by DropBits. Some compressors need this method, as the flush different amount
  103. of data than they read in. Normally the GetBits functions are used.
  104. When including the source file directly, do not forget to set the correct defines
  105. to include the necessary functions. */
  106.  
  107. #if !defined(XADIODIRECTMODE) || defined(XADIOGETBITSLOW)
  108. /* new bytes inserted from left, get bits from right end, max 32 bits, no checks */
  109. XADIOFUNCMODEBITS ULONG xadIOGetBitsLow(struct xadInOut *io, UBYTE bits);
  110. #endif
  111.  
  112. #if !defined(XADIODIRECTMODE) || defined(XADIOREADBITSLOW)
  113. XADIOFUNCMODEBITS ULONG xadIOReadBitsLow(struct xadInOut *io, UBYTE bits);
  114. XADIOFUNCMODEBITS void xadIODropBitsLow(struct xadInOut *io, UBYTE bits);
  115. #endif
  116.  
  117. #if !defined(XADIODIRECTMODE) || defined(XADIOGETBITSHIGH)
  118. /* new bytes inserted from right, get bits from left end, max 32 bits, no checks */
  119. XADIOFUNCMODEBITS ULONG xadIOGetBitsHigh(struct xadInOut *io, UBYTE bits);
  120. #endif
  121.  
  122. #if !defined(XADIODIRECTMODE) || defined(XADIOREADBITSHIGH)
  123. XADIOFUNCMODEBITS ULONG xadIOReadBitsHigh(struct xadInOut *io, UBYTE bits);
  124. XADIOFUNCMODEBITS void xadIODropBitsHigh(struct xadInOut *io, UBYTE bits);
  125. #endif
  126.  
  127. #endif /* XADMASTER_XADIO_H */
  128.